package cn.tedu.review;

import java.io.*;

/**本类用于复习常用流对象的创建方式*/
public class CreateStream {
    public static void main(String[] args) {
        f1();//用于复习字节流对象的创建
        f2();//用于复习字符流对象的创建
    }

    private static void f1() {
        try {
            //字节输入流
//            InputStream in = new FileInputStream()//这样写也可以，多态写法
            FileInputStream in = new FileInputStream(new File("C:\\kaifa\\ready\\1.1txe"));
            FileInputStream in2 = new FileInputStream("C:\\kaifa\\ready\\1.1txe");
            BufferedInputStream in3 = new BufferedInputStream(new FileInputStream(new File("C:\\kaifa\\ready\\1.1txe")));
            BufferedInputStream in4 = new BufferedInputStream(new FileInputStream("C:\\kaifa\\ready\\1.1txe"));
            //字节输出流
//            OutputStream out = new FileOutputStream("");//可以，多态写法
            FileOutputStream out = new FileOutputStream(new File("C:\\kaifa\\ready\\1.1txe"));
            FileOutputStream out2 = new FileOutputStream("C:\\kaifa\\ready\\1.1txe");
            FileOutputStream out3 = new FileOutputStream(new File("C:\\kaifa\\ready\\1.1txe"),true);
            FileOutputStream out4 = new FileOutputStream("C:\\kaifa\\ready\\1.1txe",true);
            //高效字节输出流需要的参数是OS,但是我们传入的是FOS，以上4个流都可以作为参数传入
            BufferedOutputStream out5 = new BufferedOutputStream(out);
            BufferedOutputStream out6 = new BufferedOutputStream(new FileOutputStream(new File("C:\\kaifa\\ready\\1.1txe")));
            BufferedOutputStream out7 = new BufferedOutputStream(new FileOutputStream("C:\\kaifa\\ready\\1.1txe"));
            BufferedOutputStream out8 = new BufferedOutputStream(new FileOutputStream(
                    new File("C:\\kaifa\\ready\\1.1txe"),true));
            BufferedOutputStream out9 = new BufferedOutputStream(new FileOutputStream("C:\\kaifa\\ready\\1.1txe",true));

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void f2() {
        try {
            //字符输入流
//            Reader in = new FileReader("");//多态写法
            FileReader in = new FileReader(new File(""));
            FileReader in2 = new FileReader("");
            BufferedReader in3 = new BufferedReader(new FileReader(new File("")));
            BufferedReader in4 = new BufferedReader(new FileReader(""));
            //字符输出流
//            Writer out = new FileWriter("")//多态写法
            FileWriter out = new FileWriter(new File(""));
            FileWriter out2 = new FileWriter("");
            FileWriter out3 = new FileWriter(new File(""),true);
            FileWriter out4 = new FileWriter("",true);
            BufferedWriter out5 = new BufferedWriter(out4);
            BufferedWriter out6 = new BufferedWriter(new FileWriter(new File("")));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
